package com.liu.thread.ch04;

public class TicketWindow implements Runnable{

	/**
	 * 表示有100张票
	 * 注意：增加了static表示3个窗口公用100张票
	 */
	private  int ticket = 10;
	
	@SuppressWarnings("static-access")
	@Override
	public void run() {
		
		//因为不是卖1张票。所以用循环
		while(true){
			if(ticket>0){
				
				try {
					Thread.currentThread().sleep(10);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println(Thread.currentThread().getName()+"售票。票号为："+ticket);
				ticket = ticket-1;
			}else{
				break;
			}
		}
	}

}



